#include "NodeContainer.h"

NodeContainer::NodeContainer() { }

NodeContainer::~NodeContainer() {
  for (std::list<Node*>::iterator it = children.begin();it!=children.end();++it) {
    delete *it;
  }
}

void NodeContainer::processNodes(llvm::IRBuilder<> *builder) {
  for (std::list<Node*>::iterator it = emittable.begin();it!=emittable.end();++it) {
    Node* node = *it;
    node->process(builder);
    node->propagateValues(); //which will add items to this list
  }
}

void NodeContainer::promoteChild(Node* node) {
  emittable.push_back(node);
}

void NodeContainer::addNode(Node* child) {
  children.push_back(child);
  child->checkForPromotion();
}

